#include "Soil.h"

Soil::Soil(shared_ptr<Man > DigDug):
    _DigDug(DigDug),
    _hole_tracker_col(0),
    _hole_tracker_row(0)

{}

void Soil::initialise()
{
    GameElement::initialise(0,100,0,0,SOIL);

    _hole_tracker.clear();
    _hole_tracker.resize( 28, vector<bool >(14,false) );

    //init the soil vector paddin
    //top
    for ( int i= 0; i < 27; i++)
    {
       _hole_tracker.at(i).at(0) = true;

    }
    //bottom
    for ( int i= 0; i != 27; i++)
    {
       _hole_tracker.at(i).at(13) = true;
    }
    //left
    for ( int i= 0; i != 13; i++)
    {
       _hole_tracker.at(0).at(i) = true;
    }
    //right
    for ( int i= 0; i != 13; i++)
    {
       _hole_tracker.at(27).at(i) = true;
    }

    //init hole tracker vector with starting holes.
    _hole_tracker[4][9] = true;
    _hole_tracker[5][9] = true;
    _hole_tracker[6][9] = true;
    _hole_tracker[7][9] = true;
    _hole_tracker[8][9] = true;
    _hole_tracker[9][9] = true;

    _hole_tracker[18][7] = true;
    _hole_tracker[18][8] = true;
    _hole_tracker[18][9] = true;
    _hole_tracker[18][10] = true;
    _hole_tracker[18][11] = true;

    _hole_tracker[20][3] = true;
    _hole_tracker[21][3] = true;
    _hole_tracker[22][3] = true;
    _hole_tracker[23][3] = true;
    _hole_tracker[24][3] = true;

    _hole_tracker[5][2] = true;
    _hole_tracker[5][3] = true;
    _hole_tracker[5][4] = true;
    _hole_tracker[5][5] = true;
}

void Soil::update()
{
    if (_DigDug->get_pos_x()%50==0 && _DigDug->get_pos_y()%50==0)
    {
        _hole_tracker_col = _DigDug->get_pos_x()/50 + 1;
        _hole_tracker_row = (_DigDug->get_pos_y()/50) -1;
        _hole_tracker[_hole_tracker_col][_hole_tracker_row] = true;
    }
}

bool Soil::get_hole_tracker(int col, int row)
{
    return _hole_tracker.at(col).at(row);
}
